# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import redis
import json
import redisclient
from log.logger import getLogger
from userproxy.proxyiptest import MyProxyIpTest
import logging
LOG=getLogger("ProxyIpRedisPipeline", logging.DEBUG)

class ProxyIpRedisPipeline(object):


    def process_item(self, item, spider):
        obj=dict(item)
        redisclient.writeToRedis(json.dumps(obj))
        LOG.info("item values is %s", json.dumps(obj))
        MyProxyIpTest().testProxyIp(obj['ip'], obj['port'])
